package com.gxa.saas.portal.service.impl;

import com.gxa.saas.core.vo.EditOderVo;
import com.gxa.saas.core.vo.TbAddressVo;
import com.gxa.saas.portal.mapper.EditOderMapper;
import com.gxa.saas.portal.mapper.ProductMapper;
import com.gxa.saas.portal.service.InsertIndentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Service;

/**
 * @Auther: pengxtao
 * @Date: 2022/7/24下午9:53
 */
@Service
public class InsertIndentServiceImpl implements InsertIndentService {

    @Autowired
    @Qualifier("MyJmsTemplate")
    private JmsMessagingTemplate jmsMessagingTemplate=null;

    private static final String INDENT_CACHE = "indentCachess";

    private static final String SELECT_PAYMESSAGE = "payMessageCache";

    @Autowired
    private ProductMapper productMapper;
    @Autowired
    private EditOderMapper editOderMapper;


    @Override
    public void insertIndentMQ(String key) {
        //发送修改商品的编号goodsCache
        // success为true表示数据库中存在该编号对应的商品, 发生的是修改操作
        System.out.println(key+"_____________________");

        jmsMessagingTemplate.convertAndSend(INDENT_CACHE,key);

    }

    @Override
    public void insertIndentSeletPayKey(String key) {

        jmsMessagingTemplate.convertAndSend(SELECT_PAYMESSAGE,key);
    }

    @Override
    public void insertIndent(EditOderVo editOderVo) {
        this.productMapper.insertIndent(editOderVo);
    }

    @Override
    public void insertIndents(TbAddressVo tbAddressVo) {
        this.productMapper.insertIndents(tbAddressVo);
    }

    @Override
    public void updateOrderStatus(String oderId) {
        this.productMapper.updateOrderStatus(oderId);
    }


    @Override
    public void insertGoodsOder(EditOderVo editOderVo) {
        this.editOderMapper.insertGoodsOder(editOderVo);
    }

    @Override
    public String selectPrIdAndId(String prId) {
        return this.productMapper.selectPrIdAndId(prId);
    }

    @Override
    public void updateProductSales(EditOderVo editOderVo) {
        this.editOderMapper.updateProductSales(editOderVo);

    }



}
